package com.nuts.core.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.nuts.base.core.BaseServiceImpl;
import com.nuts.base.core.IBaseDao;
import com.nuts.core.bean.request.LookupReqVO;
import com.nuts.core.bean.response.LookupVO;
import com.nuts.core.dao.ILookupDao;
import com.nuts.core.service.ILookupService;

/**
 * lookup业务实现
 * 
 * @author 许自辉
 * @date 2017年7月24日 下午3:35:08
 */
@Service
public class LookupImpl extends BaseServiceImpl<LookupReqVO, LookupVO> implements ILookupService {

	private ILookupDao lookupDao;

	@Autowired
	@Override
	public void setBaseDao(IBaseDao<LookupReqVO, LookupVO> baseDao) {
		this.baseDao = baseDao;
		this.lookupDao = (ILookupDao) baseDao;
	}

	@Override
	public int insert(LookupReqVO record) {
		LookupReqVO lookup = new LookupReqVO();
		lookup.setCode(record.getCode());
		LookupVO reLookup = lookupDao.get(record);
		if (null == reLookup) {
			return lookupDao.insert(record);
		} else {
			return -1;
		}
	}
}
